package com.gongpb.langchain4j.demo.lowlevel;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatLanguageModelController {
    /**
     * 用于与DeepSeek的AI聊天模型进行交互的语言模型实例
     */
    private final ChatLanguageModel chatLanguageModel;

    public ChatLanguageModelController() {
        this.chatLanguageModel = OpenAiChatModel.builder()
                .apiKey("sk-eaf66d0e33164c6a8a232062e4a8be0a")
                .baseUrl("https://api.deepseek.com/v1")
                .modelName("deepseek-chat")
                .build();
    }

    @GetMapping("/model")
    public String model(@RequestParam(value = "message", defaultValue = "Hello") String message) {
        String result = chatLanguageModel.chat(message);
        System.out.println("start - message = " + message+" \n result = " + result);
        return result;
//    return "Hello, " + message;
    }
}